package com.deschen.security.core.validate.code.image;

import com.deschen.security.core.validate.code.AbstractValidateCodeProcessor;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.ServletWebRequest;

import javax.imageio.ImageIO;

/**
 * @Author deschen
 * @Create 2019/8/21
 * @Description 图片验证码处理器
 * @Since 1.0.0
 */
@Component("imageValidateCodeProcessor")
public class ImageValidateCodeProcessor extends AbstractValidateCodeProcessor<ImageValidateCode> {

    @Override
    protected void send(ServletWebRequest request, ImageValidateCode imageValidateCode) throws Exception {
        ImageIO.write(imageValidateCode.getImage(), "JPEG", request.getResponse().getOutputStream());
    }
}
